package com.xintool.Utils;

import javax.swing.*;
import java.awt.*;

public class IconManager {
    private static Image icon;

    static {
        loadIcon();
    }

    private static void loadIcon() {
        try {
            // 从资源文件夹加载图标（支持PNG/JPG）
            icon = new ImageIcon(IconManager.class.getResource("/icons/app_icon.ico")).getImage();
        } catch (Exception e) {
            System.out.println("图标加载失败，使用默认图标");
        }
    }


    // 为窗口设置图标
    public static void setIcon(Window window) {
        if (window instanceof JFrame) {
            (window).setIconImage(icon);
        } else if (window instanceof JDialog) {
            (window).setIconImage(icon);
        }
    }
}

